package com.seraph.zys.dao.impl;

import com.seraph.bi.suite.support.domain.pagination.PageBox;
import com.seraph.bi.suite.support.domain.pagination.PageObject;
import com.seraph.zys.dao.ScRoleDAO;
import com.seraph.zys.dao.domain.ScRole;
import com.seraph.zys.dao.domain.ScRoleExample;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

@Repository
public class ScRoleDAOImpl extends SqlMapClientDaoSupport implements ScRoleDAO {

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    public ScRoleDAOImpl() {
        super();
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    public Integer insert(ScRole record) {
        Object newKey = getSqlMapClientTemplate().insert("sc_role.abatorgenerated_insert", record);
        return (Integer) newKey;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    public int updateByPrimaryKey(ScRole record) {
        int rows = getSqlMapClientTemplate().update("sc_role.abatorgenerated_updateByPrimaryKey", record);
        return rows;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    public int updateByPrimaryKeySelective(ScRole record) {
        int rows = getSqlMapClientTemplate().update("sc_role.abatorgenerated_updateByPrimaryKeySelective", record);
        return rows;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    public List selectByExample(ScRoleExample example, String orderByClause) {
        Map parms = getExampleParms(example);
        if (orderByClause != null) {
            parms.put("ABATOR_ORDER_BY_CLAUSE", orderByClause);
        }
        List list = getSqlMapClientTemplate().queryForList("sc_role.abatorgenerated_selectByExample", parms);
        return list;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    public List selectByExample(ScRoleExample example) {
        return selectByExample(example, null);
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    public ScRole selectByPrimaryKey(Integer id) {
        ScRole key = new ScRole();
        key.setId(id);
        ScRole record = (ScRole) getSqlMapClientTemplate().queryForObject("sc_role.abatorgenerated_selectByPrimaryKey", key);
        return record;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    public int deleteByExample(ScRoleExample example) {
        int rows = getSqlMapClientTemplate().delete("sc_role.abatorgenerated_deleteByExample", getExampleParms(example));
        return rows;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    public int deleteByPrimaryKey(Integer id) {
        ScRole key = new ScRole();
        key.setId(id);
        int rows = getSqlMapClientTemplate().delete("sc_role.abatorgenerated_deleteByPrimaryKey", key);
        return rows;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    private Map getIDExampleParms(ScRoleExample example) {
        Map parms = new HashMap();
        switch (example.getId_Indicator()) {
        case ScRoleExample.EXAMPLE_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_NULL", "Y");
            } else {
                parms.put("AND_ID_NULL", "Y");
            }
            break;
        case ScRoleExample.EXAMPLE_NOT_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_NOT_NULL", "Y");
            } else {
                parms.put("AND_ID_NOT_NULL", "Y");
            }
            break;
        case ScRoleExample.EXAMPLE_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_EQUALS", "Y");
            } else {
                parms.put("AND_ID_EQUALS", "Y");
            }
            parms.put("id", example.getId());
            break;
        case ScRoleExample.EXAMPLE_NOT_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_NOT_EQUALS", "Y");
            } else {
                parms.put("AND_ID_NOT_EQUALS", "Y");
            }
            parms.put("id", example.getId());
            break;
        case ScRoleExample.EXAMPLE_GREATER_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_GT", "Y");
            } else {
                parms.put("AND_ID_GT", "Y");
            }
            parms.put("id", example.getId());
            break;
        case ScRoleExample.EXAMPLE_GREATER_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_GE", "Y");
            } else {
                parms.put("AND_ID_GE", "Y");
            }
            parms.put("id", example.getId());
            break;
        case ScRoleExample.EXAMPLE_LESS_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_LT", "Y");
            } else {
                parms.put("AND_ID_LT", "Y");
            }
            parms.put("id", example.getId());
            break;
        case ScRoleExample.EXAMPLE_LESS_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ID_LE", "Y");
            } else {
                parms.put("AND_ID_LE", "Y");
            }
            parms.put("id", example.getId());
            break;
        }
        return parms;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    private Map getROLE_NAMEExampleParms(ScRoleExample example) {
        Map parms = new HashMap();
        switch (example.getRoleName_Indicator()) {
        case ScRoleExample.EXAMPLE_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_NAME_NULL", "Y");
            } else {
                parms.put("AND_ROLE_NAME_NULL", "Y");
            }
            break;
        case ScRoleExample.EXAMPLE_NOT_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_NAME_NOT_NULL", "Y");
            } else {
                parms.put("AND_ROLE_NAME_NOT_NULL", "Y");
            }
            break;
        case ScRoleExample.EXAMPLE_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_NAME_EQUALS", "Y");
            } else {
                parms.put("AND_ROLE_NAME_EQUALS", "Y");
            }
            parms.put("roleName", example.getRoleName());
            break;
        case ScRoleExample.EXAMPLE_NOT_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_NAME_NOT_EQUALS", "Y");
            } else {
                parms.put("AND_ROLE_NAME_NOT_EQUALS", "Y");
            }
            parms.put("roleName", example.getRoleName());
            break;
        case ScRoleExample.EXAMPLE_GREATER_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_NAME_GT", "Y");
            } else {
                parms.put("AND_ROLE_NAME_GT", "Y");
            }
            parms.put("roleName", example.getRoleName());
            break;
        case ScRoleExample.EXAMPLE_GREATER_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_NAME_GE", "Y");
            } else {
                parms.put("AND_ROLE_NAME_GE", "Y");
            }
            parms.put("roleName", example.getRoleName());
            break;
        case ScRoleExample.EXAMPLE_LESS_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_NAME_LT", "Y");
            } else {
                parms.put("AND_ROLE_NAME_LT", "Y");
            }
            parms.put("roleName", example.getRoleName());
            break;
        case ScRoleExample.EXAMPLE_LESS_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_NAME_LE", "Y");
            } else {
                parms.put("AND_ROLE_NAME_LE", "Y");
            }
            parms.put("roleName", example.getRoleName());
            break;
        case ScRoleExample.EXAMPLE_LIKE:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_NAME_LIKE", "Y");
            } else {
                parms.put("AND_ROLE_NAME_LIKE", "Y");
            }
            parms.put("roleName", example.getRoleName());
            break;
        }
        return parms;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    private Map getROLE_ALIASExampleParms(ScRoleExample example) {
        Map parms = new HashMap();
        switch (example.getRoleAlias_Indicator()) {
        case ScRoleExample.EXAMPLE_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_ALIAS_NULL", "Y");
            } else {
                parms.put("AND_ROLE_ALIAS_NULL", "Y");
            }
            break;
        case ScRoleExample.EXAMPLE_NOT_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_ALIAS_NOT_NULL", "Y");
            } else {
                parms.put("AND_ROLE_ALIAS_NOT_NULL", "Y");
            }
            break;
        case ScRoleExample.EXAMPLE_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_ALIAS_EQUALS", "Y");
            } else {
                parms.put("AND_ROLE_ALIAS_EQUALS", "Y");
            }
            parms.put("roleAlias", example.getRoleAlias());
            break;
        case ScRoleExample.EXAMPLE_NOT_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_ALIAS_NOT_EQUALS", "Y");
            } else {
                parms.put("AND_ROLE_ALIAS_NOT_EQUALS", "Y");
            }
            parms.put("roleAlias", example.getRoleAlias());
            break;
        case ScRoleExample.EXAMPLE_GREATER_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_ALIAS_GT", "Y");
            } else {
                parms.put("AND_ROLE_ALIAS_GT", "Y");
            }
            parms.put("roleAlias", example.getRoleAlias());
            break;
        case ScRoleExample.EXAMPLE_GREATER_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_ALIAS_GE", "Y");
            } else {
                parms.put("AND_ROLE_ALIAS_GE", "Y");
            }
            parms.put("roleAlias", example.getRoleAlias());
            break;
        case ScRoleExample.EXAMPLE_LESS_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_ALIAS_LT", "Y");
            } else {
                parms.put("AND_ROLE_ALIAS_LT", "Y");
            }
            parms.put("roleAlias", example.getRoleAlias());
            break;
        case ScRoleExample.EXAMPLE_LESS_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_ALIAS_LE", "Y");
            } else {
                parms.put("AND_ROLE_ALIAS_LE", "Y");
            }
            parms.put("roleAlias", example.getRoleAlias());
            break;
        case ScRoleExample.EXAMPLE_LIKE:
            if (example.isCombineTypeOr()) {
                parms.put("OR_ROLE_ALIAS_LIKE", "Y");
            } else {
                parms.put("AND_ROLE_ALIAS_LIKE", "Y");
            }
            parms.put("roleAlias", example.getRoleAlias());
            break;
        }
        return parms;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    private Map getDESCRIPTIONExampleParms(ScRoleExample example) {
        Map parms = new HashMap();
        switch (example.getDescription_Indicator()) {
        case ScRoleExample.EXAMPLE_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_NULL", "Y");
            } else {
                parms.put("AND_DESCRIPTION_NULL", "Y");
            }
            break;
        case ScRoleExample.EXAMPLE_NOT_NULL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_NOT_NULL", "Y");
            } else {
                parms.put("AND_DESCRIPTION_NOT_NULL", "Y");
            }
            break;
        case ScRoleExample.EXAMPLE_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_EQUALS", "Y");
            } else {
                parms.put("AND_DESCRIPTION_EQUALS", "Y");
            }
            parms.put("description", example.getDescription());
            break;
        case ScRoleExample.EXAMPLE_NOT_EQUALS:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_NOT_EQUALS", "Y");
            } else {
                parms.put("AND_DESCRIPTION_NOT_EQUALS", "Y");
            }
            parms.put("description", example.getDescription());
            break;
        case ScRoleExample.EXAMPLE_GREATER_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_GT", "Y");
            } else {
                parms.put("AND_DESCRIPTION_GT", "Y");
            }
            parms.put("description", example.getDescription());
            break;
        case ScRoleExample.EXAMPLE_GREATER_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_GE", "Y");
            } else {
                parms.put("AND_DESCRIPTION_GE", "Y");
            }
            parms.put("description", example.getDescription());
            break;
        case ScRoleExample.EXAMPLE_LESS_THAN:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_LT", "Y");
            } else {
                parms.put("AND_DESCRIPTION_LT", "Y");
            }
            parms.put("description", example.getDescription());
            break;
        case ScRoleExample.EXAMPLE_LESS_THAN_OR_EQUAL:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_LE", "Y");
            } else {
                parms.put("AND_DESCRIPTION_LE", "Y");
            }
            parms.put("description", example.getDescription());
            break;
        case ScRoleExample.EXAMPLE_LIKE:
            if (example.isCombineTypeOr()) {
                parms.put("OR_DESCRIPTION_LIKE", "Y");
            } else {
                parms.put("AND_DESCRIPTION_LIKE", "Y");
            }
            parms.put("description", example.getDescription());
            break;
        }
        return parms;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    private Map getExampleParms(ScRoleExample example) {
        Map parms = new HashMap();
        parms.putAll(getIDExampleParms(example));
        parms.putAll(getROLE_NAMEExampleParms(example));
        parms.putAll(getROLE_ALIASExampleParms(example));
        parms.putAll(getDESCRIPTIONExampleParms(example));
        return parms;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    public int selectCountByExample(ScRoleExample example) {
        Map parms = getExampleParms(example);
        int count = ((Integer)getSqlMapClientTemplate().queryForObject("sc_role.abatorgenerated_selectCountByExample", parms)).intValue();
        return count;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    public PageBox selectByExampleWithPaging(ScRoleExample example, int pageSize, int pageNum, String orderByClause) {
        Map parms = getExampleParms(example);
        if (orderByClause != null) {
            parms.put("ABATOR_ORDER_BY_CLAUSE", orderByClause);
        }
        PageBox pageBox = new PageBox();
        PageObject pageObject = new PageObject();
        pageObject.setPageSize(pageSize);
        pageObject.setPageIndex(pageNum);
        int itemAmount = selectCountByExample(example);
        pageObject.setItemAmount(itemAmount);
        List pageList = null;
        if (pageObject.getBeginIndex() <= pageObject.getItemAmount()) {
            pageList = (getSqlMapClientTemplate().queryForList("sc_role.abatorgenerated_selectByExample", parms, pageObject.getBeginIndex() - 1, pageSize));
        }
        pageBox.setPageObject(pageObject);
        pageBox.setPageList(pageList);
        return pageBox;
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    public PageBox selectByExampleWithPaging(ScRoleExample example, int pageSize, int pageNum) {
        return selectByExampleWithPaging(example, pageSize, pageNum, null);
    }

    /**
     * This method was generated by Abator for iBATIS.
     * This method corresponds to the database table sc_role
     *
     * @abatorgenerated Tue Sep 20 22:24:44 CST 2011
     */
    public int updateByPrimaryKeyForCgs(ScRole record) {
        int rows = getSqlMapClientTemplate().update("sc_role.abatorgenerated_updateByPrimaryKeyForCgs", record);
        return rows;
    }
}